#ifndef GROUP_CENTER_H
#define GROUP_CENTER_H

#include <map>
#include <string>
#include "messageBase.h"
#include "singleGroup.h"
#include "singleMember.h"

class groupCenter
{
public:
	~groupCenter();

	int getCountOfGroup() const;
	bool isGroupExisted(const std::string &name) const;
	singleGroup *getGroupByName(const std::string &name) const;

	singleGroup *createGroup(const std::string &name, singleMember *leader);
	void releaseGroup(const std::string &name);
	void releaseAllGroup();

	bool sendMessageToGroup(messageBase *msg, const std::string &groupname);
	bool sendMessageToGroupLeader(messageBase *msg, const std::string &groupname);

	void DelMemberFromAllGroup(const std::string &name);
	void DelMemberFromGroup(const std::string &group, const std::string &name);

private:
	std::map<std::string, singleGroup *> m_all_group_list; 
};

#endif
